extends IEventActuator


class_name RangeSetter
"""
用于修改RangeComponent数据的组件
"""


## 操作逻辑
@export var method: RangeComponent.RangeMethod = RangeComponent.RangeMethod.None
## 操作值
@export var value: int = 0
## 操作的组件
@export var finder_or_node: Node = null


func __check_exports() -> Dictionary:
    return IComponent.merge({
        "method": func(): return method != RangeComponent.RangeMethod.None,
        "finder_or_node": IComponent.find_child.bind(self, func(x): return x is INodeFinder, finder_or_node),
    }, super.__check_exports())

func get_wrapper() -> RangeComponent:
    return finder_or_node.find() if finder_or_node is INodeFinder else finder_or_node

func execute() -> void:
    var range_component: RangeComponent = get_wrapper()
    if not range_component:
        return
    range_component.execute(method, value)
